﻿namespace Sai.Cecil
{
	using Sai.Core.Introspection;
	using Mono.Cecil;

	/// <summary>
	/// Factory type extension to build a declarations from equivalent mono definition objects.
	/// </summary>
	public static class EventDefinitionExtensions
	{
		/// <summary>
		/// Creates an event declaration from an event definition.
		/// </summary>
		/// <param name="e">The event.</param>
		/// <returns>The event object.</returns>
		public static EventDeclaration ToEventDeclaration(this EventDefinition e)
		{
			var eventType = new EventDeclaration(
								e.Name,
								e.EventType.ToTypeName(),
								e.BuildObsoleteMarker(),
								e.DeclaringType.ToTypeName());

			//// e. has parameters ???

			return eventType;
		}
	}
}
